<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      function Counter() {
        let i = 0;
        // this = {}
        this.up = function () {
          console.log(i++);
        };
        this.down = function () {
          console.log(i--);
        };
        // return this;
      }
      const c = new Counter();
      c.up();
      c.up();
      c.up();
      c.down();
      c.down();
      c.down();
      c.down();
    </script>
  </body>
</html>
